package util;

import java.io.BufferedWriter;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import test.domain.environment.file.ResultFile;

public class FileManager {
	public void writeFile(String fileName, StringBuilder sb) throws Exception {
		// Write to file
		File outFile = new File(fileName);
		
		if (outFile.exists()) {
			if (outFile.delete()) {
				System.out.println(outFile.getName() + " is deleted.");
			}
			else {
				throw new IllegalStateException("Delete operation is failed.");
			}	
		}			
		
		BufferedWriter out = new BufferedWriter(new java.io.FileWriter(outFile));
		out.write(sb.toString());
		out.close();
	}
}
